package com.example.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.example.dao.PointsRepository;
import com.example.entity.Points;

@Service
public class PointsService {
	@Resource
	private PointsRepository orderRepository;

	@Transactional
	public Points addPoints(Integer memberId, Integer points) {
		Points entity = orderRepository.findById(memberId).get();
		entity.setPoints(entity.getPoints() + points);
		return orderRepository.save(new Points(memberId, entity.getPoints()));
	}
}
